#ifndef EUQT_H
#define EUQT_H

//these warnings don't work, or work different in cpp file
//4.5beta trips this
#if QT_VERSION < 0x040500
//~ #warning You may need to upgrade to Qt a 4.5.x release
#endif

//4.5beta doesn't trip this
#if QT_VERSION >= 0x040900
//~ #warning You may need to upgrade to Qt >= 0x040900
#endif

#include <QtCore/qglobal.h>
#include <QtCore/QVariant>
#include <QtCore/QMetaObject>
#include <QtCore/QTimer>
#include <QtGui>

#include <QtUiTools>
//~ #include <Phonon>

//~ #include <QtScript>
//~ #include <QtSql>

//Forward declarations
class QSqlQuery;
class QScriptEngine;
class QScriptValue;
class simpleWidget;

typedef void (*EuCallProc)(void);
typedef void (*EuCallProcP)(void*);
typedef void (*EuCallProcB)(void*, bool);
typedef void (*EuCallProcIII)(void*, int, int, int);

typedef void (*EuCallProcI)(void*, int);
typedef void (*EuCallProcS)(void*, const QString &);



#ifdef __cplusplus

class SimpleReceiver: public QObject
{
	Q_OBJECT

	int rid;
	QWidget *widget;

public:
	SimpleReceiver(QWidget *widget, const char *name, int rid)
	{
		setObjectName(name);
		this->widget = widget;
		this->rid = rid;
	}

public slots:
	void slot(void);
	void slotWidget();
	void slot(bool b1);
	void slot(const QDate &date);
	void slot(int i);
	void slot(const QString &string);
};

#endif  /*cplusplus */

//need to seperate out the class definition so can call from *.c

#ifdef __cplusplus
extern "C"
{
#endif

	size_t strlcpy(char *dest, const char *src, size_t maxlen);
	size_t strlcat(char *dest, const char *src, size_t maxlen);

	QClipboard *qt_clipboard(QApplication *app=qApp);
	void qt_setText(QObject *widget, const char *t, const char *mime="text");
	void qt_appendText(QObject *widget, const char *t);
	const char *qt_text(QObject *widget, const char *mime="text");
	simpleWidget *qt_simpleWidget(QWidget *parent);
	const char *msgstring(int msg);

	//~ singleShot *qt_singleShot(QApplication *app); //?QCore?
	QTimer *qt_Timer(QApplication *app=qApp); //?QCore?
	bool qt_stopTimer(QTimer *t);
	bool qt_startTimer(QTimer *t);
	bool qt_setIntervalTimer(QTimer *t, int n);
	QProcess *qt_Process(QObject *parent);
	bool qt_startProcess(QProcess *pros, const char *prog, char **args);
	const char *qt_readProcess(QProcess *pros);
	bool qt_closeProcess(QProcess *pros);
	bool qt_killProcess(QProcess *pros);
	int qt_errorProcess(QProcess *pros);
	const char *qt_errorStringProcess(QProcess *pros);

	//I needs to be a qvarient, sometimes need string, string
	QSettings *qts_settings(const char *F, int I, QWidget *parent);
	bool qts_contains(QSettings *S, const char *K);
    	void qts_remove (QSettings *S, const char *K);

	//V should be a qvarient. for now all values are strings
	bool qts_setValue(QSettings *S, const char *K,const char *V);
	const char *qts_value(QSettings *S, const char *K);
	void qts_endGroup(QSettings *S);
	void qts_beginGroup(QSettings *S, const char *G);


	QApplication *qt_app();  //returns qApp
	const char *qt_plugin_info();
	const char *qt_version_info();
	const char *qt_widget_info(QObject *widget);

	QCoreApplication *qt_init_noGUI(int argc, char **argv);
	QApplication *qt_init(int argc, char **argv);
//~ default param
	bool qt_run(bool once = 0, QApplication * app = qApp);
	QWidget *qt_parentWidget(QWidget *w);
	void qt_setParent(QWidget *w,  QWidget *parent);


	void qt_destroy(QWidget *w);

	void qt_show(QWidget *w);
	void qt_setFocus(QWidget *widget);

	void qt_resize(QWidget *widget, int width, int height);
	void qt_move(QWidget *widget, int x, int y);
	void qt_setWindowIcon(QWidget *widget, const char * icon);

	void qt_setWindowTitle(QWidget *widget, const char * t);
	void qt_setTabOrder(QWidget *widget, QWidget * first, QWidget * second);
	void qt_setWindowFlag(QWidget *widget, int flag);
	void qt_resetWindowFlag(QWidget *widget, int flag);
	void qt_setAttribute(QWidget *widget, int attr, bool setreset);
	bool qt_acceptDrops(QWidget *widget, int setreset=-1);


	void qt_display(QWidget *widget, const char * t);


	const char *qt_get_string_prop(QWidget *w, const char *prop);
	bool qt_get_bool_prop(QWidget *w, const char *prop);
	int qt_get_int_prop(QWidget *w, const char *prop);

	const char *qt_get_struct_prop(QWidget *w, const char *prop);
	const char *qt_getProps(QWidget *widget);
	const char *qt_getChildrenNames(QWidget *widget);

	QWidget *qt_loadUi(const char *string, QWidget *parent);

	QWidget *qt_findChild(QWidget *parent, const char *name, const char *oftype);
	bool qt_connect(QWidget *w, const char *signal, const char *slot, int rid);
	bool qt_disconnect(QWidget *w, const char *signal, const char *slot);
	
	bool qt_inherits(QWidget *w, const char *aclass);


	bool qt_setStyle(QWidget *widget, const char *style);
	const char *qt_getStyles(void);

	const char *qt_tr(QApplication *qt, const char *s, char **v, const char * disambiguation, int n);



	void qt_addItems(QObject *widget, char **values, const char *oftype);


	const char *qt_get_open_filename(QWidget *parent, const char *cap, const char *dir, const char *filter, int opts);


	void qt_about(QWidget *parent, const char *title, const char *message);
	void qt_about_qt(QWidget *parent, const char *title);
	int qt_critical(QWidget *parent, const char *title, const char *message, int buttons, int defaultButton);
	int qt_information(QWidget *parent, const char *title, const char *message, int buttons, int defaultButton);
	int qt_question(QWidget *parent, const char *title, const char *message, int buttons, int defaultButton);
	int qt_warning(QWidget *parent, const char *title, const char *message, int buttons, int defaultButton);

	void qt_treewidget_set_header_text(QTreeWidget *widget, int column, const char *name);
	void qt_treewidget_add(QTreeWidget *widget, char **values);

	int qt_FontDialog();
	int qt_ColorDialog();
	
	bool qt_db_isDriverAvailable(const char *drivername);
	const char *qt_db_DriversAvailable(const char *drivername);
	bool qt_db_removeDatabase(const char *name);
	bool qt_db_addDatabase(const char *driver, const char *name);
	const char *qt_db_lastError(const char *dbname);
	QSqlQuery *qt_db_Query(const char *q);
	bool qt_db_exec(QSqlQuery *query, const char *q);
	
	bool qt_db_transaction(const char *dbname);
	bool qt_db_rollback(const char *dbname);
	bool qt_db_commit(const char *dbname);
	bool qt_db_isOpenError(const char *dbname);
	bool qt_db_isOpen(const char *dbname);
	
	bool qt_db_isActive(QSqlQuery *query);
	bool qt_db_isValid(QSqlQuery *query);
	bool qt_db_first(QSqlQuery *query);
	bool qt_db_next(QSqlQuery *query);
	bool qt_db_last(QSqlQuery *query);
	bool qt_db_previous(QSqlQuery *query);
	bool qt_db_isForwardOnly(QSqlQuery *query);
	void qt_db_setForwardOnly(QSqlQuery *query, bool forward );
	bool qt_db_isSelect(QSqlQuery *query);
	bool qt_db_isNull(QSqlQuery *query, int field);
	bool qt_db_seek(QSqlQuery *query, int index);
	const char *qt_db_value(QSqlQuery *query, int index);
	//~ qt_db_bindValue(QSqlQuery *query, const char *);
	//~ qt_db_prepare(QSqlQuery *query, const char *);

	//~ const char *qt_Xml_lastError(QXml *Xml);

	QScriptEngine *qt_scriptengine_create();
	int qt_scriptengine_eval_integer(QScriptEngine *engine, const char *s);
	float qt_scriptengine_eval_float(QScriptEngine *engine, const char *s);
	const char *qt_scriptengine_eval_string(QScriptEngine *engine, const char *s);
	const QScriptValue  *qt_scriptengine_eval_script(QScriptEngine *engine, const char *s);

	void qt_QGLsetOption(int opt );
	bool qt_hasOpenGL();
	FILE *stdFILE(int c);

#ifdef __cplusplus
}  /* extern "C" */
#endif



#endif
